"use strict";
/**
 * @ Author: Yoann Meclot. MSay2
 * @ Created on: 2020-09-29 11:23:15
 * @ Modified on: 2021-06-11 20:15:06
 *
 * @version 1.1
 */
/**
 * Copyright (c) 2020-2021 MSay2 (Yoann Meclot) - @msay2/tspoet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSProperty = void 0;
const ArrayList_js_1 = require("../util/list/ArrayList.js");
const LinkedMap_js_1 = require("../util/list/LinkedMap.js");
const Utils_js_1 = require("../util/Utils.js");
const ObjectName_js_1 = require("./ObjectName.js");
/**
 * TSProperty allows you to write an interface property.
 *
 * @class `TSProperty`
 * @version 1.0
 */
class TSProperty {
    constructor(builder) {
        this.mName = builder.mName;
        this.mDocs = builder.mDocs;
        this.mParameters = builder.mParameters;
        this.mType = builder.mType;
    }
    /**
     * Init a builder for add a interface method or property.
     *
     * @param name The name of the method or property.
     * @throws {TSPoetException} Check if the name is undefined or null.
     * @type {Builder}
     * @since 1.0
     */
    static propertyBuilder(name) {
        return new TSProperty.Builder(name);
    }
    emit(codeWriter) {
        codeWriter.emitProperty(this);
        return codeWriter;
    }
}
exports.TSProperty = TSProperty;
TSProperty.Builder = class Builder {
    constructor(name) {
        this.mParameters = new LinkedMap_js_1.LinkedMap();
        this.mDocs = new ArrayList_js_1.ArrayList();
        this.mType = ObjectName_js_1.ObjectName.ANY;
        this.mName = Utils_js_1.Preconditions.checkNotNull(name, "property name", "name");
    }
    /**
     * Add parameter.
     *
     * @param name The parameter name.
     * @param objectName The parameter type.
     * @throws {TSPoetException} Check if the name parameter is undefined or null.
     * @throws {TSPoetException} Check if the ObjectName object is undefined or null.
     * @type {TSProperty.Builder}
     * @since 1.0
     */
    addParameter(name, objectName) {
        this.mParameters.add(Utils_js_1.Preconditions.checkNotNull(name, "parameter name", "name"), Utils_js_1.Preconditions.checkNotNull(objectName, "parameter type", "type"));
        return this;
    }
    /**
     * Add documentation.
     *
     * @param arg Your documentation.
     * @throws {TSPoetException} Check if the doc is undefined or null.
     * @type {TSProperty.Builder}
     * @since 1.0
     */
    addDoc(arg) {
        this.mDocs.add(Utils_js_1.Preconditions.checkNotNull(arg, "property documentation", "string argument"));
        return this;
    }
    /**
     * Set return type.
     *
     * @param objectName The return type.
     * @throws {TSPoetException} Check if the ObjectName object is undefined or null.
     * @type {TSProperty.Builder}
     * @since 1.0
     */
    return(objectName) {
        this.mType = Utils_js_1.Preconditions.checkNotNull(objectName, "property type", "type");
        return this;
    }
    /**
     * Build property.
     *
     * @type {TSProperty}
     * @since 1.0
     */
    build() {
        return new TSProperty(this);
    }
};
//# sourceMappingURL=TSProperty.js.map